<?php //pr($related_games); ?>
<?php 
function getUrl() {
  $url  = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] :  'https://'.$_SERVER["SERVER_NAME"];
  $url .= $_SERVER["REQUEST_URI"];
  return $url;
}
// pr($game); exit;
?>
<div id="breadclumb">
	<?php echo $this->Html->link('Trang chủ', DOMAIN_ROOT); ?>
	<span class="icon-breadclumb"></span>
	<?php echo $this->Html->link($game['Genre'][0]['name'], '/'); // cần sửa lại url ?>
	<span class="icon-breadclumb"></span>
	<?php echo $game['Game']['name']; ?>
</div>
<?php echo $this->Session->flash(); ?>
<div id="content-game">
	<h2 class="title-head"><?php echo $game['Game']['name']; ?></h2>
	<div id="box-content">
		<div class="images">
			<?php echo $this->Html->image($game['Game']['thumbnail'], array('class' => 'game-image', 'width' => 435, 'height' => 280)); ?>
		</div>
		<div class="info-right">
			<div class="soc">
				<span><div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/vi_VN/all.js#xfbml=1&appId=446371708808024";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script></span>
				<?php echo $this->Html->link('<span class="icon-fb"></span>', 'http://www.facebook.com/share.php?u=' . getUrl(), array('escape' => false, 'target' => '_blank'));?>
				<?php echo $this->Html->link('<span class="icon-twitter"></span>', '#', array('escape' => false, 'target' => '_blank'));?>
				<?php //echo $this->Html->link('<span class="icon-google"></span>', 'https://www.google.com.vn/bookmarks/mark?op=add&bkmk=' . getUrl(), array('escape' => false, 'target' => '_blank'));?>
				
				<a href="
	javascript:(
	  function(){
		var w=480;var h=380;
		var x=Number((window.screen.width-w)/2);
		var y=Number((window.screen.height-h)/2);
		window.open('https://plusone.google.com/_/+1/confirm?hl=en&url='+encodeURIComponent(location.href)+'
			&title='+encodeURIComponent(document.title),'','width='+w+',height='+h+',left='+x+',top='+y+',
			scrollbars=no');
  	  })();">
	<span class="icon-google"></span></a>
			</div>
			<p><?php echo $game['Game']['description']; ?></p>
			<p>Nhà phát hành: <?php echo $this->Html->link('<span>'.$game['Publisher']['name'].'</span>', '/', array('escape' => false)); //Cần thay đổi ?></p>
			<?php if($game_rate != 0) :?>
				<p>Đánh giá trung bình: <span><?php echo $rate[0][0]['points']/ $game_rate; ?> điểm (<?php echo $game_rate; ?> người bình chọn)</span><br>
			<?php else : ?>
				<p>Đánh giá game:</p>
			<?php endif; ?>
					<?php echo $this->Form->postLink($this->Html->image('style-appstore/rat.png'), array('controller' => 'rates', 'action' => 'add', 1, $game['Game']['id']), array('title' => 'Đánh giá cho game này 2 điểm', 'alt' => 'rate', 'escape' => false)); ?>
					<?php echo $this->Form->postLink($this->Html->image('style-appstore/rat.png'), array('controller' => 'rates', 'action' => 'add', 2, $game['Game']['id']), array('title' => 'Đánh giá cho game này 2 điểm', 'alt' => 'rate', 'escape' => false)); ?>
					<?php echo $this->Form->postLink($this->Html->image('style-appstore/rat.png'), array('controller' => 'rates', 'action' => 'add', 3, $game['Game']['id']), array('title' => 'Đánh giá cho game này 3 điểm', 'alt' => 'rate', 'escape' => false)); ?>
					<?php echo $this->Form->postLink($this->Html->image('style-appstore/rat.png'), array('controller' => 'rates', 'action' => 'add', 4, $game['Game']['id']), array('title' => 'Đánh giá cho game này 4 điểm', 'alt' => 'rate', 'escape' => false)); ?>
					<?php echo $this->Form->postLink($this->Html->image('style-appstore/rat.png'), array('controller' => 'rates', 'action' => 'add', 5, $game['Game']['id']), array('title' => 'Đánh giá cho game này 5 điểm', 'alt' => 'rate', 'escape' => false)); ?>
			</p>
			<p>
				<div class="fb-like" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button_count" data-action="like" data-show-faces="true" data-share="true"></div>
				<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
				<g:plusone></g:plusone>
			</p>
			<p>Lượt xem: <span>3250</span></p>
			<p>Lượt tải: <span>3250</span></p>
			<p>
				<?php
					if(!empty($game['System'][0])) {
						echo $this->Html->link($this->Html->image('style-appstore/android-download.png'), $game['System'][0]['GamesSystem']['download'], array('escape' => false));
					}
					
					if(!empty($game['System'][1])) {
						echo $this->Html->link($this->Html->image('style-appstore/ios-download.png'), $game['System'][1]['GamesSystem']['download'], array('escape' => false));
					}
					
					if(!empty($game['System'][2])) {
						echo $this->Html->link($this->Html->image('style-appstore/windowsphone-download.png'), $game['System'][2]['GamesSystem']['download'], array('escape' => false));
					}
				?>
				
			</p>
			<div class="tagcloud">
				<p>Tag: 
					<?php foreach($game['Tag'] as $tag){
						echo $this->Html->link('<span>'.$tag['name'].'</span>', DOMAIN_ROOT.'/tag/'.$tag['alias'], array('escape' => false)).',  '; // can thay doi
					}?>
				</p>
			</div>
		</div>
		<div style="clear: both"></div>
		<!---------------------------------------------------------------------------------------------->
		
		<div id="tabContainer">
		
		<div id="tabs">
			<ul>
				<li id="tabHeader_1">Giới thiệu</li>
				<li id="tabHeader_2">Hình ảnh game</li>
				<li id="tabHeader_3">Bình luận</li>
				
			</ul>
		</div>
		<div style="clear: both"></div>
		<div id="tabscontent">
			<div class="tabpage" id="tabpage_1">
				
				<p><?php echo $game['Game']['description']; ?></p>

			</div>
			
			<div class="tabpage" id="tabpage_2">
				<p>
					<?php 
						foreach ($game['Image'] as $image) {
							echo $this->Html->image($image['url']);
						}
					?>
				</p>
			</div>
			
			
			
			<div class="tabpage" id="tabpage_3">
				<section id="form-comment">
					<?php
						echo $this->Form->create('Comment', array('url' => array('controller' => 'comments', 'action' => 'add'), 'inputDefaults' => array('label' => false)));
						echo $this->Form->textarea('content', array('placeholder' => 'Nhập bình luận của bạn vào đây...'));
						echo $this->Form->input('game_id', array('value' => $game['Game']['id'], 'type' => 'text', 'hidden' => true, 'div' => false));
						echo $this->Form->submit('Gửi bình luận', array('class' => 'comment-submit', 'div' =>false));
						echo $this->Form->end();
					?>
					
				</section>
				<div style="clear: both"></div>
				<?php
					if(isset($comments)) :
						foreach($comments as $comment):
				?>
				<section id="box-comment">
					<p class="user-info"><?php echo $comment['User']['username']; ?> - <span><?php echo date('d/m/Y', $comment['Comment']['created']); ?></span></p>
					<p class="comment"><?php echo $comment['Comment']['content']; ?></p>
				</section>
				<?php 
						endforeach;
					endif;
				?>
				
			</div>
			
		</div>
		</div>
	</div>
</div>